import Http from '@/utils/Http';
import { Uri } from '@/constant/Constants';
import PostCategory from '@/model/PostCategory';
import PostInfo from '@/model/PostInfo';
import { PostResponse } from '@/protocol/response/PostResponse';
import { PostRequest } from '@/protocol/request/PostRequest';
import ProtocolResponse from '@/protocol/response/ProtocolResponse';
import LoggerUtil from '@/utils/LoggerUtil';
import UniUtil from '@/utils/UniUtil';

export namespace PostService {

    export async function queryRecommendList(request: PostRequest.QueryList) {
        return  Http.request(Uri.post_recommend_list_query, request, new Array<PostInfo>(), false);
    }

    export async function queryUserList(request: PostRequest.QueryList) {
        return  Http.request(Uri.post_user_list_query, request, new Array<PostInfo>(), false);
    }
    
    export async function queryUserLikeList(request: PostRequest.QueryList) {
        return  Http.request(Uri.post_user_like_list_query, request, new Array<PostInfo>(), false);
    }
    
    export async function queryUserCollectList(request: PostRequest.QueryList) {
        return  Http.request(Uri.post_user_collect_list_query, request, new Array<PostInfo>(), false);
    }

    export async function likePost(postId: number) {
        let request = new PostRequest.Action();
        request.postId = postId;
        return  Http.request(Uri.post_action_like, request, new ProtocolResponse(), true);
    }

    export async function unlikePost(postId: number) {
        let request = new PostRequest.Action();
        request.postId = postId;
        return  Http.request(Uri.post_action_unlike, request, new ProtocolResponse(), true);
    }
    
    export async function collectPost(postId: number) {
        let request = new PostRequest.Action();
        request.postId = postId;
        return  Http.request(Uri.post_action_collect, request, new ProtocolResponse(), true);
    }     
    
    export async function uncollectPost(postId: number) {
        let request = new PostRequest.Action();
        request.postId = postId;
        return  Http.request(Uri.post_action_uncollect, request, new ProtocolResponse(), true);
    }

    export async function sharePost(postId: number) {
        let request = new PostRequest.Action();
        request.postId = postId;
        return  Http.request(Uri.post_action_share, request, new ProtocolResponse(), true);
    }
}